﻿@model Inspinia_MVC5_SeedProject.ViewModels.InstructorIndexData

@{
    ViewBag.Title = "Instructors";
}

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>Index</h2>
        <ol class="breadcrumb">
            <li class="active">
                <strong>Instructor</strong>
            </li>
        </ol>
    </div>
</div>


<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>List of Instructor</h5>
					<div class="ibox-tools">
						@Html.ActionLink("Create New", "Create", null, new { @class = "btn btn-primary btn-xs"})
					</div>
                </div>
                <div class="ibox-content">

<table class="table table-striped">
    <tr>
        <th>
            Last Name
        </th>
        <th>
            First name
        </th>
        <th>
            Hire Date
        </th>
        <th>
            Office
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.Instructors)
{
    string selectedRow = "";
    if (item.ID == ViewBag.InstructorID)
    {
        selectedRow = "success";
    }
    <tr class="@selectedRow">
        <td>
            @Html.ActionLink(item.LastName, "Index", new { id = item.ID })
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FirstMidName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.HireDate)
        </td>
        <td>
            @if (item.OfficeAssignment != null)
            {
                @item.OfficeAssignment.Location;
            }
        </td>
        <td>
            
            @Html.ActionLink("Details", "Details", new { id = item.ID }, new { @class = "btn btn-primary btn-sm" })
            @Html.ActionLink("Edit", "Edit", new { id = item.ID }, new { @class = "btn btn-white btn-sm" })
            @Html.ActionLink("Delete", "Delete", new { id = item.ID }, new { @class = "btn btn-white btn-sm" })
        </td>
    </tr>
}

</table>

                    @if(Model.Courses != null)
                    {
                        <h3>Courses Taught by Selected Instructor</h3>
                        <table class="table">
                            <tr>
                                <th>Number</th>
                                <th>Title</th>
                                <th>Department</th>
                            </tr>

                            @foreach(var item in Model.Courses)
                            {
                                string selectedRow = "";
                                if (item.CourseID == ViewBag.CourseID)
                                {
                                    selectedRow = "success";
                                }
                                <tr class="@selectedRow">
                                    <td>
                                        @Html.ActionLink(item.CourseID.ToString(), "Index", new { courseID = item.CourseID })
                                    </td>
                                    <td>
                                        @item.Title
                                    </td>
                                    <td>
                                        @item.Department.Name
                                    </td>
                                </tr>
                            }
                        </table>
                    }
                    
                    @if (Model.Enrollments != null)
                    {
                        <h3>
                            Students Enrolled in Selected Course
                        </h3>
                        <table class="table">
                            <tr>
                                <th>Name</th>
                                <th>Grade</th>
                            </tr>
                            @foreach (var item in Model.Enrollments)
                            {
                                <tr>
                                    <td>
                                        @item.Student.FullName
                                    </td>
                                    <td>
                                        @Html.DisplayFor(modelItem => item.Grade)
                                    </td>
                                </tr>
                            }
                        </table>
                    }
                    
                </div>
            </div>
        </div>
    </div>
 </div>



